*** Title: Replication material for the article "Europe matters... upon closer investigation. A novel approach for analysing individual-level determinants of vote choice across first- and second-order elections, applied to 2019 Italy" 
*** Authors: Angelucci D., De Sio L., Paparo A.
*** Date: 11/06/2020
*** Software: Stata 14
/*** Additional packages to be installed: lassopack (module for lasso, square-root 
	 lasso, elastic net, ridge, adaptive lasso estimation and cross-validation). 
	 Package lassopack from http://fmwww.bc.edu/RePEc/bocode/l */
	 
********************************************************************************
***            SECTION 1: VALIDATION MODEL "NORMAL VOTE"					 ***
********************************************************************************

ssc install fitstat
ssc install lassopack

* 1.1. Preliminary setting
use "_replication_dataset", clear //Use dataset in long(stacked by party) form
recode cred*(.=0.5) // Recode missing credibilities (missing = 0.5)

* 1.2. Replication Table 1

** 1.2.1. Model without satisfaction for government and party credibilities (Controls for: gender, education, age, left/right self-placement)
eststo clear
eststo ses: logit normal_vote pidpart_ yn_sex1_tot yn_titstu5_tot yn_age_tot yn_lrself_0_tot 
fitstat

** 1.2.2. Model including satisfaction for government and party credibilities (Controls for: gender, education, age, left/right self-placement)
eststo ses_cred: logit normal_vote pidpart_ yn_* cred* 
fitstat

esttab using normal_vote.rtf, p pr2 label mtitle wide star(+ .10 * .05 ** .01 *** .001) replace

********************************************************************************
*** SECTION 2: BIVARIATE ANALYSIS OF DEFECTIONS IN EP AND GENERAL ELECTIONS	 ***
********************************************************************************

* 2.1. Preliminary setting
keep if normal_vote==1 // Keep only normal voters (725 observations overall)


* 2.2. Replication Table 2, Single issue models (Controls for: sex, age, education)

** 2.2.1 Defections in European Elections
eststo clear
* Bivariate regression with positional issues as predictors
local controls = "party_num##(c.sex1 c.age c.titstu5)"
foreach v of numlist 1/19  {  
	eststo: logit EU_ cred_p`v'_ `controls'
	}	
* Bivariate regression with valence issues as predictors
local controls = "party_num##(c.sex1 c.age c.titstu5)"
foreach v of numlist 1/11  { 
	eststo: logit EU_ cred_v`v'_ `controls'
	}	
	
esttab using Eu_defections_bivariate.rtf, p pr2 label mtitle wide star(+ .10 * .05 ** .01 *** .001) replace

** 2.2.2. Defections in general elections (Controls for: sex, age, education)
eststo clear	
* Bivariate regression with positional issues as predictors
local controls = "party_num##(c.sex1 c.age c.titstu5)"
foreach v of numlist 1/19  { 
	eststo: logit POL_ cred_p`v'_ `controls'
	}	
* Bivariate regression with valence issues as predictors
local controls = "party_num##(c.sex1 c.age c.titstu5)"
foreach v of numlist 1/11  { 
	eststo: logit POL_ cred_v`v'_ `controls'
	}	
	
esttab using Pol_defections_bivariate.rtf, p pr2 label mtitle wide star(+ .10 * .05 ** .01 *** .001) replace





********************************************************************************
***  			SECTION 3: MULTIVARIATE MODEL WITH ALL ISSUES           	 ***
********************************************************************************

* 3.1. Replication Table 2, Full models (Controls for: sex, age, education)

** 3.1.1. Defections in EP Elections
local controls = "party_num##(c.sex1 c.age c.titstu5)"
eststo clear
eststo: logit EU_ cred* `controls'
fitstat	
esttab using Eu_defections_full_model.rtf, se pr2 label mtitle wide star(+ .10 * .05 ** .01 *** .001) replace

** 3.1.2. Defections in General Elections
local controls = "party_num##(c.sex1 c.age c.titstu5)"
eststo clear
eststo: logit POL_ cred* `controls'	
fitstat
esttab using Pol_defections_full_model.rtf, se pr2 label mtitle wide star(+ .10 * .05 ** .01 *** .001) replace




********************************************************************************
*** 			SECTION 4: LASSO REGRSSION ANALYSIS 						 ***
********************************************************************************

* 4.1. Replication Table 3 (Controls for: sex, age, education)
log using "lASSO_estimator.txt", text replace


** 4.1.1. Lasso logit for defections in EU elections	
local controls = "party_num##(c.sex1 c.age c.titstu5)"	
lassologit EU_ cred* `controls', notpen(`controls')
eststo Eu_defections: lassologit, lic(ebic)

** 4.1.2. Lasso logit for defections in general elections
local controls = "party_num##(c.sex1 c.age c.titstu5)"	
lassologit POL_ cred* `controls', notpen(`controls')
eststo Pol_defections: lassologit, lic(ebic)

log close

	




	
